<rd-header>
  <rd-header-title title="Secrets list">
    <a data-toggle="tooltip" title="Refresh" ui-sref="secrets" ui-sref-opts="{reload: true}">
      <i class="fa fa-refresh" aria-hidden="true"></i>
    </a>
    <i id="loadingViewSpinner" class="fa fa-cog fa-spin" style="margin-left: 5px;"></i>
  </rd-header-title>
  <rd-header-content>Secrets</rd-header-content>
</rd-header>

<div class="row">
  <div class="col-lg-12 col-md-12 col-xs-12">
    <rd-widget>
      <rd-widget-header icon="fa-user-secret" title="Secrets">
      </rd-widget-header>
      <rd-widget-taskbar classes="col-lg-12 col-md-12 col-xs-12">
        <div class="pull-left">
          <button type="button" class="btn btn-danger" ng-click="removeAction()" ng-disabled="!state.selectedItemCount"><i class="fa fa-trash space-right" aria-hidden="true"></i>Remove</button>
          <a class="btn btn-primary" type="button" ui-sref="actions.create.secret">Add secret</a>
        </div>
        <div class="pull-right">
          <input type="text" id="filter" ng-model="state.filter" placeholder="Filter..." class="form-control input-sm" />
        </div>
      </rd-widget-taskbar>
      <rd-widget-body classes="no-padding">
        <div class="table-responsive">
          <table class="table table-hover">
            <thead>
              <th>
                <input type="checkbox" ng-model="allSelected" ng-change="selectItems(allSelected)" />
              </th>
              <th>
                <a ui-sref="secrets" ng-click="order('Name')">
                  Name
                  <span ng-show="sortType == 'Name' && !sortReverse" class="glyphicon glyphicon-chevron-down"></span>
                  <span ng-show="sortType == 'Name' && sortReverse" class="glyphicon glyphicon-chevron-up"></span>
                </a>
              </th>
              <th>
                <a ui-sref="secrets" ng-click="order('CreatedAt')">
                  Created at
                  <span ng-show="sortType == 'Image' && !sortReverse" class="glyphicon glyphicon-chevron-down"></span>
                  <span ng-show="sortType == 'Image' && sortReverse" class="glyphicon glyphicon-chevron-up"></span>
                </a>
              </th>
            </thead>
            <tbody>
              <tr dir-paginate="secret in (state.filteredSecrets = ( secrets | filter:state.filter | orderBy:sortType:sortReverse | itemsPerPage: pagination_count))">
                <td><input type="checkbox" ng-model="secret.Checked" ng-change="selectItem(secret)"/></td>
                <td><a ui-sref="secret({id: secret.Id})">{{ secret.Name }}</a></td>
                <td>{{ secret.CreatedAt | getisodate }}</td>
              </tr>
              <tr ng-if="!secrets">
                <td colspan="3" class="text-center text-muted">Loading...</td>
              </tr>
              <tr ng-if="secrets.length == 0">
                <td colspan="3" class="text-center text-muted">No secrets available.</td>
              </tr>
            </tbody>
          </table>
          <div ng-if="secrets" class="pull-left pagination-controls">
            <dir-pagination-controls></dir-pagination-controls>
          </div>
        </div>
      </rd-widget-body>
    </rd-widget>
  </div>
</div>
